package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.ParsedObjectBuilder;

import java.util.ArrayList;
import java.util.List;

public class RowModelBuilder
        extends ParsedObjectBuilder<RowModel> {
    private int stretch;
    private ModelAlignment alignment;
    private List<CellModel> children;

    public RowModelBuilder() {
        this.children = new ArrayList<>();
    }

    public final RowModelBuilder setStretch(
            int stretch
    ) {
        this.stretch = stretch;
        return this;
    }

    public final RowModelBuilder setAlignment(
            ModelAlignment alignment
    ) {
        this.alignment = alignment;
        return this;
    }

    public final RowModelBuilder addCell(
            CellModel child
    ) {
        this.children.add(child);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public RowModel build() {
        return new RowModel(getLineInfo(), this.stretch, this.alignment, this.children);
    }
}
